<template>
	<view class="content">
		<view class="top p20 clo-fff line2">
			<view>我的团队：<text class="f34">{{team}}</text>人</view>
			<view>生产生收益：<text class="f34">{{money}}</text>元</view>
		</view>
		<view class="main" v-if="list.length > 0">
			<view v-for="(item,index) in list" class="bgfff pt10 pb10 ml20 mr20 mb20 pl20 pr20 line2">
				<view>{{item.u_name}}</view>
				<view class="clo-666">到期时间：{{item.u_fenxiao_end_date}}</view>
			</view>
		</view>
		<div class="listdata_desc" v-if="list.length > 0 && listdata_desc != ''">{{ listdata_desc }}</div>
		<template v-if="list.length == 0">
		    <div class="empty_box acea-row row-center-wrapper">
		        <div>
		            <div class="empty_icon">
		                <image class="img" src="/static/icon_null.png" mode="aspectFill"></image>
		            </div>
		            <div class="empty_msg">暂无数据</div>
		        </div>
		    </div>
		</template>
	</view>
</template>

<script>
	import {userList} from '@/utils/api.js'
	export default {
		data() {
			return {
				team:0,
				money:0,
				is_more:true,
				listdata_desc:'',
				list:[],
				searchFrom: {
					page: 1,
					pageSize: 20
				}
			}
		},
		//监听滑动到底部
		onReachBottom() {
			if (this.is_more) {
			    this.searchFrom.page++;
			    this.get_list();
			}
		},
		onLoad() {
			this.get_list();
		},
		methods: {
			get_list(){
				this.listdata_desc = '正在加载';
				userList(this.searchFrom).then(res=>{
					let list = res.data.list
					this.money = res.data.total_money;
					this.team = res.data.count;
					if(this.page == 1){
					    this.is_more = true;
					    this.list = [];
					}
					
					this.listdata_desc = '';
					if (list.length == 0) {
					    //阻止继续分页
					    this.is_more = false;
					    this.listdata_desc = '没有更多了';
					    return;
					}
					if (list.length < this.pageSize) {
					    this.is_more = false;
					    this.listdata_desc = '没有更多了';
					}
					if(list.length > 0){
						list.forEach(item=>{
							this.list.push(item)
						})
					}
				})
			}
		}
	}
</script>

<style>
	.content {background: linear-gradient(#3172f9 10%, #f8f8f8); min-height: 100%;}
	.main {height: 83vh; overflow-y: auto;}
</style>